package com.ruoyi.channel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.channel.domain.TbWorkType;
import com.ruoyi.channel.service.ITbWorkTypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 招聘类型Controller
 * 
 * @author ruoyi
 * @date 2023-01-29
 */
@RestController
@RequestMapping("/type")
public class TbWorkTypeController extends BaseController
{
    @Autowired
    private ITbWorkTypeService tbWorkTypeService;

    /**
     * 查询招聘类型列表
     */
    @RequiresPermissions("interview:type:list")
    @GetMapping("/list")
    public TableDataInfo list(TbWorkType tbWorkType)
    {
        startPage();
        List<TbWorkType> list = tbWorkTypeService.selectTbWorkTypeList(tbWorkType);
        return getDataTable(list);
    }

    /**
     * 导出招聘类型列表
     */
    @RequiresPermissions("interview:type:export")
    @Log(title = "招聘类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbWorkType tbWorkType)
    {
        List<TbWorkType> list = tbWorkTypeService.selectTbWorkTypeList(tbWorkType);
        ExcelUtil<TbWorkType> util = new ExcelUtil<TbWorkType>(TbWorkType.class);
        util.exportExcel(response, list, "招聘类型数据");
    }

    /**
     * 获取招聘类型详细信息
     */
    @RequiresPermissions("interview:type:query")
    @GetMapping(value = "/{workTypeId}")
    public AjaxResult getInfo(@PathVariable("workTypeId") Long workTypeId)
    {
        return success(tbWorkTypeService.selectTbWorkTypeByWorkTypeId(workTypeId));
    }

    /**
     * 新增招聘类型
     */
    @RequiresPermissions("interview:type:add")
    @Log(title = "招聘类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbWorkType tbWorkType)
    {
        return toAjax(tbWorkTypeService.insertTbWorkType(tbWorkType));
    }

    /**
     * 修改招聘类型
     */
    @RequiresPermissions("interview:type:edit")
    @Log(title = "招聘类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbWorkType tbWorkType)
    {
        return toAjax(tbWorkTypeService.updateTbWorkType(tbWorkType));
    }

    /**
     * 删除招聘类型
     */
    @RequiresPermissions("interview:type:remove")
    @Log(title = "招聘类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workTypeIds}")
    public AjaxResult remove(@PathVariable Long[] workTypeIds)
    {
        return toAjax(tbWorkTypeService.deleteTbWorkTypeByWorkTypeIds(workTypeIds));
    }
}
